package main

import (
	"fmt"
	"reflect"
)

type Vertex struct {
	X int
	Y int
	Z func(a, b int, z float64, opt ...interface{}) (success bool)
}

type Locker interface {
	Lock()
	Unlock()
}

func main() {
	// 传统的定义变量方式
	var x bool = true
	fmt.Println(x)

	// 类型推测
	x2 := true // bool
	fmt.Println(x2)

	// 数类型
	var x3 uint8 = 0 // the set of all unsigned  8-bit integers (0 to 255)
	fmt.Println(x3)
	var x4 int16 = 0 // the set of all unsigned 16-bit integers (0 to 65535)
	fmt.Println(x4)
	var x5 int32 = 123_456_789 // the set of all unsigned 32-bit integers (0 to 4294967295)
	fmt.Println(x5)
	var x6 int64 = 0 // the set of all unsigned 64-bit integers (0 to 18446744073709551615)
	fmt.Println(x6)

	var x7 int8 = 0 // the set of all signed  8-bit integers (-128 to 127)
	fmt.Println(x7)
	var x8 int16 = 0 // the set of all signed 16-bit integers (-32768 to 32767)
	fmt.Println(x8)
	var x9 int32 = 0 // the set of all signed 32-bit integers (-2147483648 to 2147483647)
	fmt.Println(x9)
	var x10 int64 = 0 // the set of all signed 64-bit integers (-9223372036854775808 to 9223372036854775807)
	fmt.Println(x10)

	var x11 float32 = 0 // the set of all IEEE-754 32-bit floating-point numbers
	fmt.Println(x11)
	var x12 float64 = 0 // the set of all IEEE-754 64-bit floating-point numbers
	fmt.Println(x12)

	var x13 complex64 = 1 + 1i // the set of all complex numbers with float32 real and imaginary parts
	fmt.Println(x13)
	var x14 complex128 = 0 - 1i // the set of all complex numbers with float64 real and imaginary parts
	fmt.Println(x14)

	// byte         alias for uint8
	// rune         alias for int32
	// uint         (architecture depended) either 32 or 64 bits
	// int          (architecture depended) same size as uint
	// uintptr      (architecture depended) an unsigned integer large enough to store the uninterpreted bits of a pointer value

	// 字符串类型
	x15 := "abc"
	fmt.Println(x15)
	// 原生字符串定义
	x16 := `a
b`
	fmt.Println(x16)

	// 数组
	var x17 []int32 = []int32{0, 1, 2}
	fmt.Println(x17)
	fmt.Println(x17[0])

	// 切片类型(slice)
	x18 := make([]int, 5, 10)
	fmt.Println(x18)
	x19 := new([10]int)[0:5]
	fmt.Println("x19:", reflect.TypeOf(x19).Kind())

	// struct
	var x20 = Vertex{1, 2, nil}
	fmt.Println(x20)

	// 指针类型
	var x21 *int = new(int)
	*x21 = 100
	fmt.Println(*x21)

	// Map 类型
	var x22 map[string]int = make(map[string]int)
	x22["a"] = 1
	fmt.Println(x22)

	// Map 类型: 复合初始化方式(composite literal)
	var x23 map[string]int = map[string]int{
		"a": 1,
		"b": 2,
	}
	fmt.Println(x23)

	// Channel 类型
	var x24 chan int32 = make(chan int32, 100) // can be used to send and receive values of type T
	fmt.Println(x24)
	// chan<- float64  // can only be used to send float64s
	// <-chan int      // can only be used to receive ints
}
